package com.zjk.wrench.design.framework.tree.node;

import com.zjk.wrench.design.framework.tree.AbstractDemoSupport;
import com.zjk.wrench.design.framework.tree.StrategyHandler;
import com.zjk.wrench.design.framework.tree.factory.DefaultStrategyFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class RootNode extends AbstractDemoSupport {

    private final SwitchNode switchNode;

    @Override
    protected String doApply(String requestParameters, DefaultStrategyFactory.DynamicContext dynamicContext) throws Exception {
        log.info("【根节点】规则决策树 requestParameters:{}",requestParameters);
        return router(requestParameters, dynamicContext);
    }

    @Override
    public StrategyHandler<String, DefaultStrategyFactory.DynamicContext, String> getStrategy(String requestParameters, DefaultStrategyFactory.DynamicContext dynamicContext) {
        return switchNode;
    }
}
